﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StripeOne.ShortenUrl.Database;

namespace StripeOne.ShortenUrl.Model.Converters
{
    public static class Converters
    {
        public static ShortenUrls ToDatabase(this ShortenModel model)
        {
            var result = new ShortenUrls();

            result.Id = model.Id;
            result.InsertDate = model.InsertDate;
            result.OriginalUrl = model.OriginalUrl;
            result.ShortUrlCode = model.Code;
            result.UserId = model.UserId;

            return result;
        }

        public static ShortenModel[] ToModel(this List<ShortenUrls> model)
        {
            var result = new List<ShortenModel>();

            foreach (var item in model)
            {
                result.Add(new ShortenModel(item));
            }

            return result.ToArray();
        }
    }
}
